#include <iostream>
#include <string>
#include <functional>
#include <pthread.h>
#include <cassert>
#include <unistd.h>

using std::string;
class Thread
{
public:
    typedef void*(*func_t)(void*);
    Thread(func_t func)
    {
        func_ = func;
        threadname_ = "tid_";
    }

    void thread_start(void* arg = nullptr)
    {
        int n = pthread_create(&tid_, nullptr, func_, arg);
        assert(n == 0);
    }
    
    void thread_join()
    {
        int n = pthread_join(tid_, arg_);
        assert(n == 0);
    }
    
    void thread_cancel()
    {
        int n = pthread_cancel(tid_);
        assert(n == 0);
    }

    ~Thread()
    {
        //
    }
private:
    pthread_t tid_;     //线程id
    string threadname_; //线程名
    func_t func_;       //线程执行函数

    void** arg_;         //返回值
};

void* threadfunc(void* name)
{
    std::cout << "运行中" << std::endl;
    return nullptr;
}
